/**
 * 
 */
package jp.tkym.labs.store.sql;

import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.SQLException;

public class SqliteConnector{
	private Connection con;
	private static final String JDBC_PATH = "org.sqlite.JDBC"; 
	private String fileName;
	
	public SqliteConnector(String fileName){
		this.fileName = fileName;
	}
	
	public void initialize()throws ClassNotFoundException, SQLException{
		Class.forName(JDBC_PATH);
		
		con = DriverManager.getConnection("jdbc:sqlite:"+path());
	}
	
	private String path(){
		return SqliteConnector.class.getResource(fileName).getPath();
	}
	
	public Connection getConnection(){
		return con;
	}
}